

/**
 * 
 * @param {Array} allRoutes 定义好的所有权限路由
 * @param {Array} menuList 从服务器返回来的用户菜单数据
 */

function recursionRoutes(allRoutes = [], menuList = []) {
  const userRoutes = []

  menuList.forEach(item => {
    allRoutes.forEach(route => {
      if (item.name === route.meta.name) {
        if (item.children && item.children.length > 0) {
          route.children = recursionRoutes
            (route.children, item.children)
        }
        userRoutes.push(route)
      }
    })
  })
  return userRoutes
}

export default recursionRoutes